﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WithInterfaces
{
    public class ActionMenuItem : MenuItem
    {
        private IExecutable m_ExecutableObj;

        public ActionMenuItem(int i_MenuItemLevel, IExecutable i_ExecutableObj)
        {
            m_MenuItemLevel = i_MenuItemLevel;
            m_ExecutableObj = i_ExecutableObj;
            m_CurrentMenuItemTitle = m_Name = i_ExecutableObj.ToString();
        }

        public override void OnClick()
        {
            System.Console.Clear();
            ShowTitle();
            m_ExecutableObj.Execute();

            throw new MenuItemException(MenuItemException.eMenuItemMessage.ExecuteFinished);
        }
    }
}